package com.svse.designPattern.structure.proxy;

import com.svse.designPattern.structure.proxy.impl.ProxyHandler;
import com.svse.designPattern.structure.proxy.impl.RealSubject;
import com.svse.designPattern.structure.proxy.service.Subject;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Copyright 上海危网信息科技有限公司版权所有
 * @company wwsoft
 * @Date 2020/7/31 8:37
 */
public class DynamicProxy {
    public static void main(String[] args) {

        Subject proxy = new RealSubject();

        InvocationHandler handler = new ProxyHandler(proxy);

        Subject dyProxy = (Subject) Proxy.newProxyInstance(proxy.getClass().getClassLoader(), proxy.getClass().getInterfaces(), handler);

        dyProxy.Request();
    }
}
